import 'package:bitcoin_flutter/bitcoin_flutter.dart';
import '../lib/coin_generate_manager.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
  test('adds one to input values', () async {
    final manager = CoinGenerateManager();

    String mnemonic = manager.generateMnemonic();

    print(mnemonic);

    String errorMnemonic = "a hj j h h i i y l o yt o";
    
    print(manager.validateMnemonic(errorMnemonic));

//    Coin eth = await manager.generateETHByDerivePath(mnemonic);
//
//    print(eth);

    /************  BTC 根据私钥生成Coin  *******************/
//    String wif = manager.privateKeyToWif("21111d81ed68e5515956b2e9d78844338c2bfa6c83e53ec356bae736c4385049");
//
//    print("wif: $wif");

    Coin btcCoin = await manager.generateCoinByPrivateKey("21111d81ed68e5515956b2e9d78844338c2bfa6c83e53ec356bae736c4385049", type: 'BTC');

    print(btcCoin.toString());
    /************ BTC 生成coin测试完成 *******************/

    /************  ETH 根据私钥生成Coin  *******************/

    Coin ethCoin = await manager.generateCoinByPrivateKey("42e2808c438b77c76f68bd302155c1f4d63b713f163f2476b026bdebd5ada2aa", type: 'ETH');

    print(ethCoin.toString());
    /************ ETH 生成coin测试完成 *******************/


    /************ 私钥合法性校验测试 *******************/
    bool isLegal = manager.validatePrivateKey("42e2808c438b77c76f68bd302155c1f4d63b713f163f2476b026bdebd5ada200");

    print("isLegal: $isLegal");
    /************ 私钥合法性校验测试 *******************/

    /************ 兑币测试 *******************/
    dynamic result =  manager.exchange(fromType: "BTC", fromNum: "1", toType: "LTC", toNum: "2");

    print("result: ${result.toString()}");
    /************ 兑币测试 *******************/


    /************ DeFi 相关 *******************/
    String  address = manager.getContractAddress("ETH");
    print("address: $address");

    String exchangeRate = manager.getExchangeRate("ETH");
    print("exchangeRate: $exchangeRate");

    dynamic deposit = manager.getDepositResult();
    print("deposit: ${deposit.toString()}");

    dynamic withdraw = manager.getWithdrawResult();
    print("withdraw: ${withdraw.toString()}");

    double interest = manager.calculateInterest(depositTime: "2019-12-15 17:00:00", apr: "0.000523");
    print("interest: $interest");

    /************ DeFi 相关 *******************/
//    TransactionResModel model = await manager.transactionBTC(mnemonic: mnemonic, fromAddress: "1GJoLVnz4TqFQ7PsS4mSvMtdPYe2btSAhW", toAddress: "1GJoLVnz4TqFQ7PsS4mSvMtdPYe2btSAh2", amount: "0.09", fee: '0.243');
//
//    print(model.toString());
//
//    List<GenCoin> genList = [
//      GenCoin(name: 'BTC', path: "m/44'/0'/0'/0/0"),
//      GenCoin(name: 'ETH', path: "m/44'/60'/0'/0/0"),
//      GenCoin(name: 'LTC', path: "m/44'/2'/0'/0/0"),
//      GenCoin(name: 'RDD', path: "m/44'/4'/0'/0/0"),
//    ];

//    List<dynamic> coins = await manager.generateCoinList(mnemonic, genList);
//
//    print("coins: $coins");


  });
}
